import Vue from 'vue'
import VueRouter from 'vue-router'
// import adminIndex from "../views/adminIndex.vue";
// import userIndex from "../views/userIndex.vue";
import login from "../components/admin/Login.vue";
import register from '../components/admin/Register.vue';
Vue.use(VueRouter)

const routes = [
  {
    path: '/admin',  //商家管理员和超管
    name: 'adminIndex',
    component: () => import("../views/adminIndex.vue"),
    children: [
      {
        path: 'login',  //登录
        name: 'Login',
        component: login,
      },
      {
        path: 'register',  //注册
        name: 'Register',
        component: register,
      },
      {
        path: 'index',  //管理主界面
        name: 'Index',
        component: () => import("../components/admin/Index.vue"),
        beforeEnter(to,from,next){
          if(sessionStorage.id){
            next()
          }else{
            next('/admin/login')
          }
       },
        children: [
          // 库存
          {
            path: 'inventory',
            name: 'inventory',
            component: () => import("../components/admin/main//manager/Inventory.vue"),
          },
          // 修改库存
          {
            path: 'updateInventory',
            name: 'updateInventory',
            component: () => import("../components/admin/main/manager/modifyInventory.vue"),
          },
          // 新增库存
          {
            path: "addInventory",
            name: "addInventory",
            component: () => import("../components/admin/main/manager/addInventory.vue")
          },
          // 库存统计
          {
            path: "echartInvenory",
            name: "echartInvenory",
            component: () => import("../components/admin/main/manager/echartInvenory.vue")
          },
          // 库存统计
          {
            path: "echartInvenory",
            name: "echartInvenory",
            component: () => import("../components/admin/main/manager/echartInvenory.vue")
          },
          // 库存统计
          {
            path: "echartInvenory",
            name: "echartInvenory",
            component: () => import("../components/admin/main/manager/echartInvenory.vue")
          },
          {
            path: 'orders', 
            name: 'orders',
            component: () => import("../components/admin/main/manager/orders.vue"),
          },
          //修改订单
          {
            path: 'updateOrders/:_id',   
            name: 'updateOrders',
            component: () => import("../components/admin/main/manager/updateOrders.vue"),
          },
          // 商品
          {
            path: 'commoditylist',
            name: 'commoditylist',
            component: () => import("../components/admin/main//manager/commoditylist.vue"),
          },
          // 新增商品
          {
            path: 'addcommodity',
            name: 'addcommodity',
            component: () => import("../components/admin/main//manager/addcommodity.vue"),
          },
          // 程鳍 门店模块
          {
            path: "putaway",
            name: "putaway",
            component: () => import('../components/admin/main/manager/putaway.vue')
          },
          {
            path: 'storeList',
            name: 'storeList',
            component: () => import("../components/store/List.vue"),
          },
          //  新增门店
          {
            path: 'storeAdd',
            name: 'storeAdd',
            component: () => import("../components/store/Add.vue"),
          },
        ]
      },
      {
        path: 'adminIndex',  //管理主界面
        name: 'adminIndex',
        component: () => import("../components/admin/adminIndex.vue"),
        children:[{
          path:'adminPerson',//管理员
          name:'adminPerson',
          component:()=>import('../components/admin/main/Padmin/adminPerson.vue')
        },{
          path:'addadmin',//新增管理员
          name:'addadmin',
          component:()=>import('../components/admin/main/Padmin/addadmin.vue')
        },
        {
          path: 'merchant',  //显示所有商家
          name: 'merchant',
          component: () => import("../components/admin/main/Padmin/merchant.vue"),
        },
        {
          path: 'freezeMerchant/:_id',  //冻结商家
          name: 'freezeMerchant',
          component: () => import("../components/admin/main/Padmin/freezeMerchant.vue"),
        },
        {
          path: 'shopList',  //显示所有店铺
          name: 'shopList',
          component: () => import("../components/admin/main/Padmin/shopList.vue"),
        },
        {
          path: 'freezeShop/:_id',  //冻结店铺
          name: 'freezeShop',
          component: () => import("../components/admin/main/Padmin/freezeShop.vue"),
        },
        {
          path: 'shShop',  //审核店铺
          name: 'shShop',
          component: () => import("../components/admin/main/Padmin/SHShop.vue"),
        },
      ]
      }
    ]
  },
  {
    path: '/user', //普通用户
    name: 'userIndex',
    component: () => import('../views/userIndex.vue'),
  },{
    path:'/homepage',
    name:'homepage',
    component:()=> import ('../views/portal/homepage.vue')
  }

]

const router = new VueRouter({
  routes
})

export default router
